/**
 * @author Justin Akin
 * @version Action Pals Core Library 0.1.0
 */
package com.actionpals.broadcasters
{	
	import flash.display.InteractiveObject;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import com.actionpals.events.WheelScrollEvent;

	public class WheelScrollCast extends AbstractScrollCast
	{
		
	//--------------------------------------------------------------------------------
	//
	//	Contstructor
	//
	//--------------------------------------------------------------------------------
	
		/**
		 * Constructor.
		 */
        public function WheelScrollCast( eventTarget:InteractiveObject )
        {	
        	super( eventTarget );
        	init();	
        }
		
	//--------------------------------------------------------------------------------
	//
	//	Protected Functions
	//
	//--------------------------------------------------------------------------------
	
		/**
		 * 
		 */
		protected function init():void
		{	
			_eventTarget.addEventListener( MouseEvent.MOUSE_WHEEL, onWheel );
		}
		
	//--------------------------------------------------------------------------------
	//
	//	Events Handlers
	//
	//--------------------------------------------------------------------------------
			
		/**
		 * 
		 */
		protected function onWheel( event:MouseEvent ):void
		{	
			var delta:int = event.delta;
			var wType:String = ( delta > 0 ) ? WheelScrollEvent.WHEEL_UP : WheelScrollEvent.WHEEL_DOWN;
			var wEvent:WheelScrollEvent = new WheelScrollEvent( wType, _eventsBubble, _eventsCancelable, delta );
			
			if( delta != 0 ) dispatchEvent( wEvent );		
		}		
	}	
}